Skip to content

perf(linked-list): measure scaling and link integrity of AddTwoNumbers (R50-T049) - #97

Open
aniruddha-bongale wants to merge 1 commit into
S-AI-Projects:masterfrom
aniruddha-bongale:student/e26b07f0827/R50-T049
Open

aniruddha-bongale wants to merge 1 commit into
S-AI-Projects:masterfrom
aniruddha-bongale:student/e26b07f0827/R50-T049

Conversation

@aniruddha-bongale

Copy link
Copy Markdown

Description

Measure the scaling behavior of AddTwoNumbers in Data-Structures/Linked-List/AddTwoNumbers.js while validating algorithm correctness. Add comprehensive complexity documentation naming the input size variable $L = \max(M, N)$, distinguishing theoretical worst-case claims from empirical observations, add regression tests with separate node link and value assertions on three distinct nodes $A \to B \to C$ and smallest supported lists, and implement an automated benchmark and test runner in work/R50-T049/check.py saving metrics to work/R50-T049/results.json.

Related Issue

Fixes: #49

Type of Change

  • Documentation update
  • Tests (adding missing tests or fixing existing tests)

Changes Made

  • Added detailed complexity analysis in Data-Structures/Linked-List/AddTwoNumbers.js documenting the input size variable $L = \max(M, N)$, theoretical worst-case time complexity $O(\max(M, N))$, and empirical observation across $L \in {100, 1000, 10000}$ nodes showing strictly linear scaling.
  • Exported Node alongside AddTwoNumbers from Data-Structures/Linked-List/AddTwoNumbers.js.
  • Added unit tests in Data-Structures/Linked-List/test/AddTwoNumbers.test.js:
    • Distinct nodes $A \to B \to C$ ($[2, 4, 3]$) and smallest supported single node ($[5]$) with separate link checks (pointer integrity) and value checks ($[7, 4, 3]$).
    • Two smallest supported single-node lists with carry ($[5] + [5] = [0, 1]$) with separate link and value checks.
    • Multi-node carry propagation ($[9, 9, 9] + [1] = [0, 0, 0, 1]$).
  • Implemented work/R50-T049/check.py to run native tests, verify link and value assertions, execute 5 repetitions per size with fixed deterministic pseudo-random seeds, measure median and range execution times isolated from process and I/O overhead, and record results in work/R50-T049/results.json.

Screenshots / Recordings

All 4 unit tests for AddTwoNumbers passed cleanly. All 5 repetitions across sizes $L \in {100, 1000, 10000}$ passed correctness checks.

Testing

  • Ran npm test -- Data-Structures/Linked-List/test/AddTwoNumbers.test.js - all 4 tests passed.
  • Executed python3 work/R50-T049/check.py - scaling and fixture assertions verified.
  • Validated Prettier formatting across all touched files.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Additional Notes

Student: Aniruddha Bongale (Enrollment: E26B07F0827)
Task ID: R50-T049

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Aniruddha Bongale — R50-T049: Measure the work done by AddTwoNumbers (AddTwoNumbers.js) [Data-Structures/Linked-List/AddTwoNumbers.js]

1 participant